jQuery(document).ready(function(e){var t=true;var n=wp.media.editor.send.attachment;e(".upload-image-button").click(function(r){var i=jQuery(this).parent();var s=wp.media.editor.send.attachment;var o=e(this);t=true;wp.media.editor.send.attachment=function(e,r){if(t){i.find(".upload-image-field").val(r.url);i.find(".image-preview").attr("src",r.url)}else{return n.apply(this,[e,r])}};wp.media.editor.open(o);return false});jQuery(".add_media").on("click",function(){t=false})})